<?php

namespace App\Providers;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

        //
        if(config("app.debug")) {
            \DB::listen(function ($query) {
                \Log::debug([$query->sql,
                    $query->bindings,
                    $query->time]);
            });
        }


        //share for current user
        $viewList = ['*'];
        view()->composer($viewList, function($view)
        {
            $currentUser = null;
            if(Auth::check()){
                $currentUser = Auth::user();
            }
            $view->with(compact('currentUser'));
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    private function getTopTitle()
    {
        $top_title= _('地址管理系统');
    }
}
